package com.lingjtx.common.pay.common;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

public enum PayChannelEnum {

    WECHAT(1),

    ALIPAY(2);

    private final int code;

    PayChannelEnum(int code) {
        this.code = code;
    }

    @JsonValue
    public int getCode() {
        return code;
    }

    @JsonCreator
    public static PayChannelEnum fromCode(int code) {
        for (PayChannelEnum value : values()) {
            if (value.code == code) {
                return value;
            }
        }
        throw new IllegalArgumentException("Invalid PayChannelEnum code: " + code);
    }
}
